package upload;

import java.io.OutputStream;
import java.io.IOException;

/**
 * 
 * @author CSDN
 *
 */
public class MyOutputStream extends OutputStream {
	
    private OutputStream out;
    private OutputStreamListener listener;

    public MyOutputStream(OutputStream out, OutputStreamListener listener) {
        this.out = out;
        this.listener = listener;
        this.listener.start();
    }
    
    @Override
	public void write(int b) {
	}

    @Override
    public void write(byte b[], int off, int len) throws IOException {
    	out.write(b,off,len);
        listener.write(len - off);
    }

    @Override
	public void close() throws IOException {
    	out.close();
        listener.end();
    }
	
}
